﻿Imports lbGlobalcom
Public Class fGeneraPlanoConverCodigo
    Dim ConvCod As GeneraPlanoConvierteCodigo

    Private Sub btnCargaDatos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCargaDatos.Click
        Try
            ConvCod = New GeneraPlanoConvierteCodigo(dtDesdeF.Value, dtHastaF.Value, txtTipoDoc.Text, DsConsultaInv.INV_AGRPACAMBIOCODIGO)
            btnGenera.Enabled = ConvCod.HayDatos
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub fGeneraPlanoConverCodigo_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Dim daTipoSub As New dsGlobalTableAdapters.GLO_DATOSTABLASTableAdapter
            daTipoSub.FillByIdGrupo(DsGlobal.GLO_DATOSTABLAS, "sp")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub btnGenera_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenera.Click
        Try
            Cursor = Cursors.WaitCursor
            ConvCod.GeneraPlano(txtRuraGenera.Text)
            MessageBox.Show("Se generarón " & ConvCod.ArchivosGenerados.ToString & " archivos con exito", "Generación Cambio", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            Cursor = Cursors.Default
        End Try
    End Sub

    Private Sub btnRuta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRuta.Click
        Try
            FBD.Description = "Ruta Generacion de Archivos"
            If FBD.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtRuraGenera.Text = FBD.SelectedPath
                My.Settings.Save()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class